#include <iostream>
#include <vector>
using namespace std;
int maxArea(vector<int> &height)
{
    int first = 0;
    int last = height.size() - 1;
    int ret = 0;
    while (first != last)
    {
        int s = (last - first) * min(height[first], height[last]);
        ret = max(ret, s);
        if (height[first] > height[last])
        {
            last--;
        }
        else
        {
            first++;
        }
    }
    return ret;
}
int main()
{
    vector<int> v = {1, 8, 6, 2, 5, 4, 8, 3, 7};
    cout << maxArea(v) << endl;
    return 0;
}